package dujiu.luogu.branch;

import java.util.Arrays;
import java.util.Scanner;

public class P4414 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int[] arr = {A,B,C};
        Arrays.sort(arr);
        String next = sc.next();
        for (String s : next.split("")) {
            if ("A".equals(s)){
                System.out.print(arr[0]+" ");
            }else if ("B".equals(s)){
                System.out.print(arr[1]+" ");
            }else {
                System.out.print(arr[2]+" ");
            }
        }
    }
}
